package P94;

import P94.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author DJ同学
 * @Date 2021/2/18 15:51
 * @Version 1.0
 * @Name 二叉树的中序遍历
 * @Problem https://leetcode-cn.com/problems/binary-tree-inorder-traversal/
 * @Idea https://www.bilibili.com/video/BV1gb411C71L?p=39
 * 中序 左子树 当前节点 右子树
 */
public class Solution {
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> res = new ArrayList<>();
        InOrder(root,res);
        return res;

    }

    private void InOrder(TreeNode root, List<Integer> res) {
        if(root!=null){
            InOrder(root.left,res);
            res.add(root.val);
            InOrder(root.right,res);
        }
    }


}
